﻿/****************************************************************************
**		File: ORelationTransfer.cs
** 		Desc: 微信-我要捐款
** 		Called by:
**
** 		Auth: 陈泳江 （chenyongjiang@sxt.com.cn）
** 		Date: 2014/5/13 14:12:47
** ===========================================================================
** 		Change History
** ===========================================================================
** 		Date:		Author:				Description:
** 		--------	--------			-------------------
**
** ===========================================================================
** Copyright (C) 2004-2011 SXT Corporation
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using ZHDJ.Core.Util;

namespace ZHDJ.MobileInterface.Common
{
    public class IWanDonations
    {
//        #region 我要捐款

//        public static string Donations(string LoginID, FieldAttribute FA)
//        {
//            Type(FA);
//            CheckPurposes(FA);
//            string ID = StringHelper.NewID;
//            FA.ID = ID;
//            FA.Status = "0";
//            FA.SignX = "";
//            FA.SignY = "";
//            DataTable dt = GetOMMassage(LoginID);
//            DataTable dta = GetBranchAddress(LoginID);
//            if (dta.Rows.Count > 0)
//            {
//                if (string.IsNullOrEmpty(FA.BranchID))
//                {
//                    FA.BranchID = dta.Rows[0]["BranchID"].ToString();
//                }
//                if (string.IsNullOrEmpty(FA.BranchName))
//                {
//                    FA.BranchName = dta.Rows[0]["BranchName"].ToString();
//                }
//                if (string.IsNullOrEmpty(FA.BranchAddress))
//                {
//                    FA.BranchAddress = dta.Rows[0]["Address"].ToString();
//                }
//            }
//            //else return "数据有误，请确认数据。";
//            if (string.IsNullOrEmpty(FA.Createby))
//            {
//                FA.Createby = LoginID;
//            }
//            if (dt.Rows.Count > 0)
//            {
//                if (string.IsNullOrEmpty(FA.CreatebyAddress))
//                {
//                    FA.CreatebyAddress = dt.Rows[0]["Address"].ToString();
//                }
//                if (string.IsNullOrEmpty(FA.CreatebyContact))
//                {
//                    FA.CreatebyAddress = dt.Rows[0]["MobileNo"].ToString();
//                }
//            }
//            //else return "数据有误，请确认数据。";

//            FA.IsEndTime = true;
//            bool IsOK=FA.Insert();
//            if (IsOK)
//            {
//                return "";
//            }
//            else return "数据有误，请检查。";
//        }

//        [SXT.Data.DBTable("tblPartyATMSaveThings")]
//        public class FieldAttribute : DataModel
//        {
//            #region 字段属性
//            [DBField(IsPrimaryKey = true)]
//            public string ID { get; set; }
//            /// <summary>
//            /// 名称
//            /// </summary>
//            [DBField]
//            public string Name { get; set; }
//            /// <summary>
//            /// 捐助名义
//            /// </summary>
//            [DBField]
//            public string Titular { get; set; }
//            /// <summary>
//            /// 捐款类型
//            /// </summary>
//            [DBField]
//            public string ThingType { get; set; }
//            /// <summary>
//            /// 捐款数量
//            /// </summary>
//            [DBField]
//            public int ThingCount { get; set; }
//            /// <summary>
//            /// 描述
//            /// </summary>
//            [DBField]
//            public string Description { get; set; }
//            /// <summary>
//            /// 设置是否可以存在到期时间
//            /// </summary>
//            [DBField]
//            public bool? IsEndTime { get; set; }
//            /// <summary>
//            /// 到期时间
//            /// </summary>
//            [DBField]
//            public DateTime? EndTime { get; set; }
//            /// <summary>
//            /// 捐助用途
//            /// </summary>
//            [DBField]
//            public string Purposes { get; set; }
//            /// <summary>
//            /// 用途说明
//            /// </summary>
//            [DBField]
//            public string PurposesDescription { get; set; }
//            /// <summary>
//            /// 捐助形式
//            /// </summary>
//            [DBField]
//            public string SaveModus { get; set; }
//            /// <summary>
//            /// 捐助人
//            /// </summary>
//            [DBField]
//            public string Createby { get; set; }
//            /// <summary>
//            /// 联系地址
//            /// </summary>
//            [DBField]
//            public string CreatebyAddress { get; set; }
//            /// <summary>
//            /// 联系方式
//            /// </summary>
//            [DBField]
//            public string CreatebyContact { get; set; }
//            /// <summary>
//            /// 组织ID
//            /// </summary>
//            [DBField]
//            public string BranchID { get; set; }
//            /// <summary>
//            /// 组织名称
//            /// </summary>
//            [DBField]
//            public string BranchName { get; set; }
//            /// <summary>
//            /// 组织地址
//            /// </summary>
//            [DBField]
//            public string BranchAddress { get; set; }
//            /// <summary>
//            /// 组织-联系人
//            /// </summary>
//            [DBField]
//            public string BranchContactPerson { get; set; }
//            /// <summary>
//            /// 组织-联系方式
//            /// </summary>
//            [DBField]
//            public string BranchContact { get; set; }
//            /// <summary>
//            /// 创建时间
//            /// </summary>
//            [DBField]
//            public DateTime? CreateTime { get; set; }

//            /// <summary>
//            /// 修改人
//            /// </summary>
//            [DBField]
//            public string ModifyBy { get; set; }
//            /// <summary>
//            /// 修改时间
//            /// </summary>
//            [DBField]
//            public DateTime? ModifyTime { get; set; }
//            /// <summary>
//            /// 是否发布
//            /// </summary>
//            [DBField]
//            public bool? IsSub { get; set; }
//            /// <summary>
//            /// 状态 0：未操作 1：已预约 2：已捐助
//            /// </summary>
//            [DBField]
//            public string Status { get; set; }

//            [DBField]
//            public string IsLoveActivity { get; set; }

//            [DBField]
//            public string SignX { get; set; }

//            [DBField]
//            public string SignY { get; set; }
//            #endregion
//        }

//        #region 不使用
//        /// <summary>
//        /// 本人
//        /// </summary>
//        /// <param name="FAMyself"></param>
//        /// <param name="LoginID"></param>
//        /// <returns></returns>
//        public static string Myself(FieldAttribute FAMyself, string LoginID)
//        {
//            DataTable dt = GetOMMassage(LoginID);
//            DataTable dta = GetBranchAddress(LoginID);
//            if (dt.Rows.Count > 0)
//            {
//                if (dta.Rows.Count > 0)
//                {
//                    string ID = StringHelper.NewID;
//                    string sqlMyself = string.Format(@" insert into tblPartyATMSaveThings(ID,Name,Titular,ThingType,ThingCount,Description,IsEndTime,EndTime,
//                                                        Purposes,PurposesDescription,SaveModus,Createby,CreatebyAddress,CreatebyContact,BranchID,BranchAddress,
//                                                        BranchContactPerson,BranchContact,CreateTime,Status,BranchName) 
//                                                         values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',
//                                                        '{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',
//                                                        '{16}','{17}','{18}','{19}','{20}')",
//        ID, FAMyself.Name, "0", FAMyself.ThingType, FAMyself.ThingCount, FAMyself.Description, 1, FAMyself.EndTime, 
//        FAMyself.Purposes, FAMyself.PurposesDescription,FAMyself.SaveModus,LoginID, dt.Rows[0]["Address"].ToString(), dt.Rows[0]["MobileNo"].ToString(), dt.Rows[0]["BranchID"].ToString(), dta.Rows[0]["Address"].ToString(),
//        "", "",DateTime.Now, 0, dta.Rows[0]["BranchName"].ToString());
//                    return "";
//                }
//                else return "登陆ID错误，请检查";
//            }
//            else return "登陆ID错误，请检查";
//        }

//        /// <summary>
//        /// 组织
//        /// </summary>
//        /// <param name="FAOrganization"></param>
////        public static string Organization(FieldAttribute FAOrganization, string LoginID)
////        {
////            DataTable dt = GetBranchIDNAme(LoginID);
////            if (dt.Rows.Count > 0)
////            {
////                string ID = StringHelper.NewID;
////                string sqlOrganization = string.Format(@" 
////INSERT INTO tblPartyATMSaveThings ([ID], [Name], [Titular], [ThingType], [ThingCount], [Description], [IsEndTime], [EndTime],
////[Purposes], [PurposesDescription], [SaveModus], [Createby], [CreatebyAddress], [CreatebyContact], [BranchID], [BranchName],[BranchAddress], 
////[BranchContactPerson], [BranchContact], [CreateTime], [Status], [SignX], [SignY]) 
////VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',
////'{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15},'{16}',
////'{17}','{18}','{19}','{20}','{21}','{22}')
////@ID, @Name, @Titular, @ThingType, @ThingCount, @Description, @IsEndTime, @EndTime, 
////@Purposes, @PurposesDescription, @SaveModus, @Createby, @CreatebyAddress, @CreatebyContact, @BranchID, @BranchName, @BranchAddress, 
////@BranchContactPerson, @BranchContact, @CreateTime, @Status, @SignX, @SignY);',N'@CVUID nvarchar(32),@ID nvarchar(32),@Name nvarchar(3),@Titular nvarchar(1),@ThingType nvarchar(1),@ThingCount nvarchar(4000),@Description nvarchar(9),@IsEndTime nvarchar(4000),@EndTime nvarchar(4000),@Purposes nvarchar(1),@PurposesDescription nvarchar(4000),@SaveModus nvarchar(1),@Createby nvarchar(5),@CreatebyAddress nvarchar(3),@CreatebyContact nvarchar(11),@BranchID nvarchar(32),@BranchName nvarchar(4),@BranchAddress nvarchar(18),@BranchContactPerson nvarchar(2),@BranchContact nvarchar(8),@CreateTime nvarchar(4000),@Status nvarchar(1),@SignX nvarchar(4000),@SignY nvarchar(4000)',@CVUID=N'f146ccb963fa45bfbc94b5942c60f866',@ID=N'f146ccb963fa45bfbc94b5942c60f866',@Name=N'资助金',@Titular=N'1',@ThingType=N'0',@ThingCount=N'123',@Description=N'124124124',@IsEndTime=N'True',@EndTime=N'2014/5/21 0:00:00',@Purposes=N'0',@PurposesDescription=N'',@SaveModus=N'0',@Createby=N'admin',@CreatebyAddress=N'434',@CreatebyContact=N'13822170275',@BranchID=N'D658070EC3BF425BA8417745FDCBFCB0',@BranchName=N'区委',@BranchAddress=N'中国广州市科学城彩频路11号D座5F',@BranchContactPerson=N'12',@BranchContact=N'14134124',@CreateTime=N'2014/5/15 15:35:37',@Status=N'0',@SignX=N'',@SignY=N''"
////    , ID, FAOrganization.Name, "1", FAOrganization.ThingType, FAOrganization.ThingCount, FAOrganization.Description, 1, FAOrganization.EndTime,
////    FAOrganization.Purposes, FAOrganization.PurposesDescription, FAOrganization.SaveModus, LoginID, FAOrganization.CreatebyAddress, FAOrganization.CreatebyContact,FAOrganization.BranchName, dta.Rows[0]["Address"].ToString(),
////            "", "", DateTime.Now, 0, dta.Rows[0]["BranchName"].ToString());
////                return "";
////            }
////        }

//        public static string Anonymous(FieldAttribute FAAnonymous)
//        {
//            return "";
//        }
//        #endregion

//        #region 类型
//        /// <summary>
//        /// 类型
//        /// </summary>
//        /// <param name="FAType"></param>
//        public static string Type(FieldAttribute FAType)
//        {
//            switch (FAType.ThingType)
//            {
//                case "0": return TypeOne(FAType.ThingType); 
//                case "1": return TypeTwo(FAType.ThingType); 
//                case "2": return TypeThree(FAType.ThingType); 
//                case "3": return TypeFour(FAType.ThingType); 
//                default: return "类型输入错误";
//            }
//        }

//        /// <summary>
//        /// 款项
//        /// </summary>
//        /// <param name="Name"></param>
//        /// <returns></returns>
//        public static string TypeOne(string Name)
//        {
//            //if (!string.IsNullOrEmpty(Name))
//            //{ 
//            //    return "当前选择捐助类型为资金，名称默认为‘资助金’，不能输入。";
//            //}
//            //else
//            //{
//            //    return "";
//            //}
//            return "";
//        }

//        /// <summary>
//        /// 物品
//        /// </summary>
//        /// <param name="Name"></param>
//        /// <returns></returns>
//        public static string TypeTwo(string Name)
//        {
//            if (!string.IsNullOrEmpty(Name))
//            {
//                return "";
//            }
//            else
//            {
//                return "当前选择捐助类型为物品，名称不能为空。";
//            }
//        }

//        /// <summary>
//        /// 服务
//        /// </summary>
//        /// <param name="Name"></param>
//        /// <returns></returns>
//        public static string TypeThree(string Name)
//        {
//            if (!string.IsNullOrEmpty(Name))
//            {
//                switch (Name)
//                {
//                    case "0":
//                    case "1":
//                    case "2":
//                    case "3":
//                    case "4":
//                    case "5":
//                    case "6":
//                    case "7":
//                    case "8": return "";
//                    default: return "所传名称不存在，请确认后输入。";
//                }
//            }
//            else
//            {
//                return "";
//            }
//        }

//        /// <summary>
//        /// 其他
//        /// </summary>
//        /// <param name="Name"></param>
//        /// <returns></returns>
//        public static string TypeFour(string Name)
//        {
//            if (!string.IsNullOrEmpty(Name))
//            {
//                return "";
//            }
//            else
//            {
//                return "当前选择捐助类型为其他，名称不能为空。";
//            }
//        }
//        #endregion

//        #region 资助用途
//        public static string CheckPurposes(FieldAttribute FACheckPurposes)
//        {
//            if (FACheckPurposes.Purposes == "2")
//            {
//                if (string.IsNullOrEmpty(FACheckPurposes.PurposesDescription))
//                {
//                    return "选择的是自定义用途，必须填写用途说明。";
//                }
//                else return "";
//            }
//            else return "";
//        }
//        #endregion

//        #region 调用方法


//        public static DataTable GetOMMassage(string LoginID)
//        {
//            string sqlGet = string.Format(@" select * from tblPartyOrgMembers where 1 =1 and LoginID='{0}' ", LoginID);
//            DataTable dt = DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteDataSet(sqlGet).Tables[0];
//            return dt;
//        }


//        public static DataTable GetBranchAddress(string LoginID)
//        {
//            string sqlGet = string.Format(@" select Orm.*,ob.* from tblPartyOrgMembers Orm
//                                            left join tblPartyOrgBranch ob on Orm.BranchID=ob.BranchID
//                                            where 1=1 and Orm.LoginID='{0}' ", LoginID);
//            DataTable dt = DBManager.DBSettings["SXT.DefaultDBEx"].ExecuteDataSet(sqlGet).Tables[0];
//            return dt;
//        }
//        #endregion

//        #endregion
    }
}